package Exercise;
import java.util.Scanner;
//汽车类
class Car{
    private String name;
    private String brand;
    private int price;
    public Car(){

    }

    public Car(String name, String brand, int price) {
        this.name = name;
        this.brand = brand;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }
}
public class Object_Array {
    public static void main(String[] args) {
        Car[] arr = new Car[2];
        Scanner sc = new Scanner(System.in);
        //键盘录入数据
        for(int i = 0;i<arr.length;i++){
            Car car = new Car();
            System.out.println("请输入车的名字：");
            car.setName(sc.next());
            System.out.println("请输入车的品牌：");
            car.setBrand(sc.next());
            System.out.println("请输入车的价格：");
            car.setPrice(sc.nextInt());
            //将对象放入对象数组中
            arr[i] = car;
        }
        //遍历
        for(int i = 0 ;i<arr.length;i++){
            System.out.println(arr[i].getName()+arr[i].getBrand()+arr[i].getPrice());
        }
    }
}
